﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Giri;

namespace Giri.L2
{
    class Identity
    {
        public static int Size = 8;
        private byte[] id;

        public Identity(byte[] data, int pos)
        {
            id = new byte[Size];
            for (int i = 0; i < Size; i++)
            {
                id[i] = data[i + pos];
            }
        }

        public Identity()
        {
            id = new byte[Size];
            new Random().NextBytes(id);
            for (int i = 0; i < Size; i++)
            {
                id[i] ^= (byte)(id[(i + 1) % Size]);
            }
        }

        public override string ToString()
        {
            string str = "0x";

            foreach (byte b in id)
            {
                str += Convert.ToString(b, 16);
            }

            return str;
        }

        public byte[] GetData()
        {
            return id;
        }
    }
}
